﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Net;
using com.lover.common;
using System.IO;
using com.lover.astd.common.model;
using com.lover.common.http;
using com.lover.astd.common.manager;

namespace com.lover.astd.common.partner.impl
{
    public class MiyouLogin : LoginImplBase
    {
        public MiyouLogin() : base() { }
        public override LoginResult login(ref List<Cookie> cookies, string verify_code = null, string extra = null)
        {
            LoginResult result = new LoginResult();
            logging();
            string loginurl = String.Format(
                "http://www.17miyou.com/DoHandler.ashx?jsonpcallback=jQuery17107724821119328832_{0}&action=dologin&uname={1}&pwd={2}&_={0}", 
                TimeMgr.TimeStamp, _username, _md5_password_lower);
            HttpResult resp = TransferMgr.doGetPure(loginurl, ref cookies);
            if (resp == null) { result.StatusCode = LoginStatusCode.FailInLogin; return result; }

            string retstr = resp.getContent();

            if (retstr.IndexOf("false") >= 0)
            {
                result.StatusCode = LoginStatusCode.FailInLogin;
                return result;
            }

            string redirecturl = String.Format("http://login.17miyou.com/InGame.aspx?gameId=913000&serverId=91300{0}", _acc.ServerId);

            processRedirect(redirecturl, result, ref cookies);
            return result;
        }
    }
}
